home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / overview / ooptesample / readme < prev    next >
Encoding:
Text File  |  2000-06-23  |  5.1 KB  |  113 lines

  1. Macintosh
  2. Sample Code Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6. #13:    OOPTESample
  7.  
  8. Written by:    Keith Rollin
  9.  
  10. Versions:            1.00                        April 1989
  11.                     1.10                        February 1990
  12.                     1.11                        June 1992
  13.  
  14. Components:            BuildOOPTESample            February 1, 1990
  15.                     MTESample.p                    February 1, 1990
  16.                     OOPTESample.make            February 1, 1990
  17.                     TECommon.h                    February 1, 1990
  18.                     TESampleGlue.a                February 1, 1990
  19.                     TESample.r                    February 1, 1990
  20.                     TMLRules.make                February 1, 1990
  21.                     UApplication.p                February 1, 1990
  22.                     UApplication.inc1.p            February 1, 1990
  23.                     UDocument.p                    February 1, 1990
  24.                     UDocument.inc1.p            February 1, 1990
  25.                     UTEDocument.p                February 1, 1990
  26.                     UTEDocument.inc1.p            February 1, 1990
  27.                     UTESample.p                    February 1, 1990
  28.                     UTESample.inc1.p            February 1, 1990
  29. _____________________________________________________________________________
  30.  
  31. READ ME TO BUILD:
  32. The build process for OOPTESample is entirely automated.  All you 
  33. need to do is run the BuildOOPTESample script.  BuildOOPTESample 
  34. is a variation on the BuildProgram script that comes standard with 
  35. MPW.  It creates a folder to contain the intermediary object 
  36. files, and then calls Make with the file OOPTESample.make.  
  37. Make’s output is executed with the final application OOPTESample 
  38. as the result.
  39. _____________________________________________________________________________
  40.  
  41. OOPTESample is an example application that demonstrates how to 
  42. initialize the commonly used Toolbox managers, operate 
  43. successfully under MultiFinder, handle desk accessories, and 
  44. create, grow, and zoom windows.  It demonstrates fundamental 
  45. TextEdit toolbox calls and TextEdit automatic scrolling, and it 
  46. shows how to create and maintain scroll bar controls.
  47.  
  48. This version of TESample has been substantially reworked in Object 
  49. Pascal to show how a “typical” object-oriented program could be 
  50. written.  To this end, what was once a single source code file has 
  51. been restructured into a set of classes which demonstrate the 
  52. advantages of object-oriented programming.
  53.  
  54. There are four main classes in this program.  Each one of these 
  55. has an interface (.p) file and an implementation (.inc1.p) file, 
  56. and is compiled into its own separate UNIT.
  57.  
  58. The TApplication class does all of the basic event handling and 
  59. initialization necessary for Macintosh Toolbox applications.  It 
  60. maintains a list of TDocument objects and passes events to the 
  61. correct TDocument class when appropriate.
  62.  
  63. The TDocument class does all of the basic document handling work.  
  64. TDocuments are objects that are associated with a window.  Methods 
  65. are provided to deal with update, activate, mouse-click, key-down, 
  66. and other events.  Some additional classes which implement a 
  67. linked list of TDocument objects are provided.
  68.  
  69. The TApplication and TDocument classes together define a basic 
  70. framework for Macintosh applications, without having any specific 
  71. knowledge about the type of data being displayed by the 
  72. application’s documents. They are a (very) crude implementation of 
  73. the MacApp application model, without the sophisticated view 
  74. hierarchies or any real error handling.
  75.  
  76. The TESample class is a subclass of TApplication.  It overrides 
  77. several TApplication methods, including those for handling menu 
  78. commands and cursor adjustment, and it does some necessary 
  79. initialization.  Note that we only need to override nine methods 
  80. to create a useful application class.
  81.  
  82. The TEDocument class is a subclass of TDocument.  This class 
  83. contains most of the special-purpose code for text editing.  In 
  84. addition to overriding most of the TDocument methods, it defines a 
  85. number of additional methods which are used by the TESample class 
  86. to get information on the document state.
  87.  
  88. This program consists of four segments.  “Main” contains most of 
  89. the code, including the MPW libraries and the main program.  
  90. “Initialize” contains code that is used only once, or rarely, and 
  91. can be unloaded after the event loop is completed.  “%A5Init” is 
  92. automatically created by the Linker to initialize globals for the 
  93. MPW libraries and is unloaded right away.  “%_MethTables” is a 
  94. fake segment used by Object Pascal to maintain object 
  95. relationships.
  96.  
  97. Toolbox routines do not change the current port.  In spite of 
  98. this, in this program we use a strategy of calling _SetPort 
  99. whenever we want to draw or make calls which depend on the current 
  100. port.  This precaution makes us less vulnerable to bugs in other 
  101. software which might alter the current port (such as the bug 
  102. (feature?) in many desk accessories which changes the port when 
  103. there is a call to _OpenDeskAcc).  Hopefully, this also makes the 
  104. routines from this program more self-contained, since they don’t 
  105. depend on the current port setting.
  106.  
  107. This program does not maintain a private scrap.  Whenever a cut, 
  108. copy, or paste occurs, we import or export from the public scrap 
  109. to TextEdit’s scrap right away, using the TEToScrap and 
  110. TEFromScrap routines.  If we did use a private scrap, the import 
  111. or export would be in the activate or deactivate event and suspend 
  112. or resume event routines.
  113.